DROP PROCEDURE COMPAREPRODUCTS

USE [shoeshop]
GO
/****** Object:  StoredProcedure [dbo].[COMPAREPRODUCTS]    Script Date: 11/23/2012 10:50:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[COMPAREPRODUCTS](@USER_IP VARCHAR(100))
AS
SELECT	TOP 5
		P.THUMBNAIL "IMAGE",
		PC.PRODUCTID,
		P.NAME "PRODUCT NAME",
		P.DESCRIPTION "DESCRIPTION",
		P.PRICE,
		D.NAME "DEPARTMENT NAME",
		C.NAME "CATEGORY NAME" 
FROM	PRODUCTCATEGORY PC, 
		CATEGORY C, 
		PRODUCT P,
		DEPARTMENT D
WHERE	PC.PRODUCTID IN (SELECT PRODUCT_ID FROM COMPARE_LOG WHERE USER_UID=@USER_IP)
AND		PC.CATEGORYID = C.CATEGORYID
AND		PC.PRODUCTID = P.PRODUCTID
AND		C.DEPARTMENTID = D.DEPARTMENTID
